package com.just.gameapp.controller;

import com.just.gameapp.entity.Match;
import com.just.gameapp.service.MatchService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zyr
 * @date 2024/6/18 下午3:07
 * @Description
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/matches")
public class MatchController {
    @Resource
    private MatchService matchService;
    @GetMapping("/list")
    public List<Match> getMatch() {
        return matchService.getList();
    }
    @PostMapping("/add")
    public Object addMatch(@ModelAttribute Match match) {
        return matchService.save(match);
    }
    @DeleteMapping("/delete/{matchId}")
    public Object deleteMatch(@PathVariable Integer matchId) {
        return matchService.removeById(matchId);
    }
    @PutMapping("/update")
    public Object updateMatch(@ModelAttribute Match match) {
        return matchService.updateById(match);
    }
    @PostMapping("/date")
    public List<Match> getMatchByDate(@ModelAttribute("param") String date){
        // 查询为2024年 大于date日的00:00:00,小于23:59:59
        return matchService.getMatchByDate(date);
    }
}
